﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

namespace HomeWork9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();


        }

        private void button1_Click(object sender, EventArgs e)
        {

            string url = textBox1.Text;
            WebClient client = new WebClient();
            byte[] pageData = client.DownloadData(url);
            string pageHtml = Encoding.Default.GetString(pageData);
            //textBox2.Text = pageHtml;

            string email_pattern = @"\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}";
            string phone_pattern = @"0([0-9]{2,3})-\d{8}";
            MatchCollection mc_email = Regex.Matches(pageHtml, email_pattern);
            MatchCollection mc_phone = Regex.Matches(pageHtml, phone_pattern);
            foreach (Match match in mc_email)
            {
                textBox2.Text = match.ToString();

            }
            foreach (Match match in mc_phone)
            {
                textBox3.Text = match.ToString();

            }

        }


    }
}
